<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
	<title>商品管理</title>
	<script src="${ctx}/static/js/imagePreview.js" type="text/javascript"></script>
	<script>
		$(document).ready(function() {
			//聚焦第一个输入框
			$("#goods_number").focus();
			//为inputForm注册validate函数
			$("#inputGoodsForm").validate();
			getImgPath('${ctx}/goods/getImgPath');
		});
	</script>
</head>

<body>
	<form id="inputGoodsForm" enctype="multipart/form-data" action="${ctx}/goods/${action}" method="post" class="form-horizontal">
		<input type="hidden" name="id" id="id" value="${goods.id}"/>
		<input type="hidden" name="uploadFileName" id="uploadFileName" value="${uploadFileName}"/>
		<fieldset>
			<legend><small>管理商品</small></legend>
			<div class="tabbable"> <!-- Only required for left/right tabs -->
 				<ul class="nav nav-tabs">
					<li class="active"><a href="#tab0" data-toggle="tab">基本信息</a></li>
					<li><a href="#tab1" data-toggle="tab">缩略图</a></li>
					<li><a href="#tab2" data-toggle="tab">高清图</a></li>
					<!-- <li><a href="#tab3" data-toggle="tab">视频</a></li> -->
				</ul>
				<div class="tab-content">
				    <div class="tab-pane active" id="tab0">
						<div class="control-group">
							<label for="goods_number" class="control-label">商品编码:</label>
							<div class="controls">
								<input type="text" id="goods_number" name="number" value="${goods.number}" class="input-large required" minlength="3"/>
							</div>
						</div>	
						<div class="control-group">
							<label for="goods_name" class="control-label">商品名称:</label>
							<div class="controls">
								<input type="text" id="goods_name" name="name" value="${goods.name}" class="input-large required" minlength="3"/>
							</div>
						</div>
						<div class="control-group">
							<label for="goods_category" class="control-label">商品分类:</label>
							<div class="controls">
								<form:select id="goods_category" path="goods.category.id">
									<form:options items="${goodsCategorys}" itemValue="id" itemLabel="name"/>
								</form:select>
							</div>
						</div>
						<div class="control-group">
							<label for="environment_name" class="control-label">商品简介:</label>
							<div class="controls">
								<div id="localImag0"><img id="prev_img0" src="" alt="简介图" /></div>
		      					<input type='file' id="doc0" name="0" onchange="readLocalImgURL(this,'0');" accept="image/png"/> 
		      					<input type='hidden' id="rid0" name="0" />
	      					</div>
      					</div>
				    </div>
				    <div class="tab-pane" id="tab1">
				    	<div class="control-group">
							<div class="controls">
				    			<div id="localImag1"><img id="prev_img1" src="" alt="缩略图" /></div>
						    	<input type='file' id="doc1" name="1" onchange="readLocalImgURL(this,'1');" accept="image/png" />
						    	<input type='hidden' id="rid1" name="1" />
				    		</div>
				    	</div>
				    </div>
				   <div class="tab-pane" id="tab2">
				   		<div class="control-group">
							<div class="controls">
						   		<div id="localImag2"><img id="prev_img2" src="" alt="高清图" /></div>
						   		<input type='file' id="doc2" name="2" onchange="readLocalImgURL(this,'2');" accept="image/png" /> 
						   		<input type='hidden' id="rid2" name="2" />
				   			</div>
				    	</div>
				  </div>
				  <!-- <div class="tab-pane" id="tab3">
				  		<div class="control-group">
							<div class="controls">
		      					<input type='file' id="doc100" name="100"  /> 
		      					<input type='hidden' id="rid100" name="100" />
      						</div>
				    	</div>
			      </div> -->
			 	</div>
			</div>

			<div class="form-actions">
				<input id="submit_btn" class="btn btn-primary" type="submit" value="提交"/>&nbsp;	
				<input id="cancel_btn" class="btn" type="button" value="返回" onclick="history.back()"/>
			</div>
		</fieldset>
	</form>
</body>
</html>